#include "vector.h"


void point_translate(punto3d* point,const vettore3d* v)
{
	point->x+=v->x;
	point->y+=v->y;
	point->z+=v->z;
}

void vector_normalize(vettore3d* v)
{
	GLfloat m=(GLfloat)sqrt(v->x*v->x + v->y*v->y + v->z*v->z);
	v->x/=m;
	v->y/=m;
	v->z/=m;
}

void vector_scale(vettore3d* v,GLfloat coeff)
{
	v->x *= coeff;
	v->y *= coeff;
	v->z *= coeff;
}
void vector_diff(vettore3d* dest,const punto3d* u,const punto3d* v)
{
	dest->x=u->x-v->x;
	dest->y=u->y-v->y;
	dest->z=u->z-v->z;
}

void vector_cross_product(vettore3d* dest,const vettore3d* u,const vettore3d* v)
{
	dest->x=(u->y*v->z) - (u->z*v->y);
	dest->y=(u->z*v->x) - (u->x*v->z);
	dest->z=(u->x*v->y) - (u->y*v->x);
	vector_normalize(dest);
}
